package com.yanftch.stopcoding.common.util

import com.intellij.openapi.application.ApplicationInfo
import com.yanftch.stopcoding.common.bean.IdeInfo
import java.text.SimpleDateFormat

fun Long.timeFormat(): String {
    val format = SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
    return format.format(this)
}

fun getIDEInfo(): IdeInfo {
    var versionName = ""
    var version = ""
    var buildNumber = ""
    try {
        val appInfo = ApplicationInfo.getInstance()
        versionName = appInfo.versionName ?: ""
        version = appInfo.fullVersion ?: ""
        buildNumber = appInfo.build.asString() ?: ""
    } catch (e: Exception) {
    }

    return IdeInfo(versionName, version, buildNumber)
}